package com.android.manager;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.content.pm.PackageInfo;
import android.content.res.Resources;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
/**
 * Android常用Manager 
 * https://segmentfault.com/a/1190000005112313
 * @author DingQingbo
 * 111
 */
@SuppressWarnings("unused")
public class ManagerD {

	public Context mContext;
	public Activity activity;

	public ManagerD() {
		super();
	}

	public ManagerD(Context context, Activity activity) {
		super();
		this.mContext = context;
		this.activity = activity;
	}

	public void setActivity(Activity activity) {
		this.activity = activity;
	}

	/**
	 * activity manager
	 */
	public static void activiryManager(Context context) {
		// 1、activitymanager
		ActivityManager aManager = null;
		aManager = (ActivityManager) context
				.getSystemService(Context.ACTIVITY_SERVICE);

		ConfigurationInfo info = aManager.getDeviceConfigurationInfo();
		info.getGlEsVersion();

	}

	/**
	 * PowerManager manager
	 * 
	 */

	public static void PowerManager(Context context) {
		PowerManager manager = (PowerManager) context
				.getSystemService(Context.POWER_SERVICE);
		

	}

	/**
	 * window manager
	 * 
	 * @param context
	 */
	@SuppressWarnings("deprecation")
	public static void windowManager(Context context) {
		WindowManager manager2 = (WindowManager) context
				.getSystemService(context.WINDOW_SERVICE);
		Display display = manager2.getDefaultDisplay();
		int height = display.getHeight();
		int width = display.getWidth();
	}

	public static void window(Activity context) {
		Window window = context.getWindow();
		
		
	}

	/**
	 * telephone Manager
	 * 
	 * @param context
	 */
	public static void telephoneManager(Context context) {
		TelephonyManager manager = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);
		manager.getNetworkOperator();

		/**
		 * 电话呼入状态监听
		 */
		PhoneStateListener listener = new PhoneStateListener() {

			@Override
			public void onCallStateChanged(int state, String incomingNumber) {
				switch (state) {
				// 无状态
				case TelephonyManager.CALL_STATE_IDLE:

					break;
				// 通话状态
				case TelephonyManager.CALL_STATE_OFFHOOK:
					break;
				// 响铃状态
				case TelephonyManager.CALL_STATE_RINGING:
					Log.d("挂断电话", "挂断");
					break;
				default:
					break;
				}
				super.onCallStateChanged(state, incomingNumber);
			}

		};
	}

	/**
	 * 
	 */
	public static void info() {
		PackageInfo packageInfo = new PackageInfo();
		// ApplicationInfo applicationInfo;
		// ActivityInfo activityInfo;
		String name = packageInfo.packageName;
	}

	/**
	 * 6.0 http://blog.csdn.net/qq_33689414/article/details/52661865
	 * 
	 * @param context
	 */
	private static void permissionManager(Context context) {

	}

	public static void resource(Activity activity) {
		Resources re = activity.getResources();
		re.getDrawable(0);
		re.getAnimation(0);
		re.getColor(0);
		re.getBoolean(0);
		re.getXml(0);
		TextView tv = new TextView(activity);
		tv.setTextColor(110);
	}

	/**
	 * location manager lbs location based services
	 * 
	 * @param context
	 */
	public static void locationManager(Context context) {
		LocationManager manager = (LocationManager) context
				.getSystemService(Context.LOCATION_SERVICE);
		String provider = LocationManager.GPS_PROVIDER;// 指定LocationManager的定位方法
		Location location = manager.getLastKnownLocation(provider);
		location.getLatitude();
		location.getLongitude();

		//
		manager.requestLocationUpdates(provider, 2000, 10,
				new LocationListener() {

					@Override
					public void onStatusChanged(String provider, int status,
							Bundle extras) {

					}

					@Override
					public void onProviderEnabled(String provider) {

					}

					@Override
					public void onProviderDisabled(String provider) {

					}

					@Override
					public void onLocationChanged(Location location) {

					}
				});

	}

	/**
	 * notification manager
	 * 
	 * @param context
	 */
	public static void notifcationManager(Context context) {
		NotificationManager manager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		// 实例化Notification
		Notification notification = new Notification();
		// 设置显示图标，该图标会在状态栏显示
		int icon = notification.icon = android.R.drawable.stat_notify_chat;
		// 设置显示提示信息，该信息也会在状态栏显示
		String tickerText = "Test Notification";
		// 显示时间
		long when = System.currentTimeMillis();
		notification.icon = icon;
		notification.tickerText = tickerText;
		notification.when = when;
		// 使用默认振动
		notification.defaults |= Notification.DEFAULT_VIBRATE;
		// 使用默认声音
		notification.defaults |= Notification.DEFAULT_SOUND;
		// 使用默认闪烁
		notification.defaults |= Notification.DEFAULT_LIGHTS;
		// 发出通知
		manager.notify(0, notification);

	}
	/**
	 * 音频管理器
	 * @param context
	 */
	public static void audioManager(Context context){
		AudioManager audioManager=(AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
	}
	/**
	 * 电量管理
	 * @param context
	 */
	public static void powerManager(Context context){
//		PowerManager	
		PowerManager manage=(PowerManager) context.getSystemService(Context.POWER_SERVICE);
	}
	
	

}


